package com.example.tnot.Teacher.CoursePart.CourseInternal.ClassDetail.VpFragment.CheckProgress.CheckProgress;

import android.os.Bundle;

import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.tnot.R;
import com.example.tnot.Teacher.BaseFragment.BaseBackFragment;
import com.example.tnot.Teacher.CoursePart.CourseInternal.ClassDetail.VpFragment.CheckProgress.Adapter.CheckProgressAdapter;
import com.example.tnot.Teacher.CoursePart.CourseInternal.ClassDetail.VpFragment.CheckProgress.ItemBean.Progress;

import java.util.ArrayList;
import java.util.List;

import kotlinx.coroutines.channels.Receive;

public class CheckProgressFragment extends BaseBackFragment {
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mParam1;
    private String mParam2;
    View view;
    ImageView iv_back;
    RecyclerView rv_students;
    private List<Progress> CheckDetail_list;
    public CheckProgressFragment() {
    }

    public static CheckProgressFragment newInstance(String param1, String param2) {
        CheckProgressFragment fragment = new CheckProgressFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view =  inflater.inflate(R.layout.course_class_check_progress, container, false);
        CheckDetail_list = new ArrayList<>();
        InitData();
        rv_students = view.findViewById(R.id.rv_students);
        CheckProgressAdapter adapter = new CheckProgressAdapter(CheckDetail_list);
        rv_students.setAdapter(adapter);
        rv_students.setLayoutManager(new LinearLayoutManager(getActivity()));

        iv_back = view.findViewById(R.id.iv_back);
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NavController navController = Navigation.findNavController(v);
                navController.navigateUp();
            }
        });
        return view;
    }

    private void InitData() {
        CheckDetail_list.add(new Progress(R.drawable.avatar1,"100%","0419230116","qqmao"));
        CheckDetail_list.add(new Progress(R.drawable.example_face,"100%","0419230116","怡心"));
    }
}